<template>
  <el-cascader
    v-model="selectedIndustry"
    :options="industryOptions"
    :props="{
      value: 'industryId',
      label: 'name',
      children: 'children',
      checkStrictly: true,
      emitPath: false
    }"
    clearable
    placeholder="请选择所属行业"
    style="width: 100%"
    @change="handleChange"
  />
</template>

<script>
import { getIndustryTree } from "@/api/enterprise/industry";

export default {
  name: "IndustrySelect",
  props: {
    value: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      selectedIndustry: this.value,
      industryOptions: []
    };
  },
  watch: {
    value(val) {
      this.selectedIndustry = val;
    }
  },
  created() {
    this.getIndustryTreeData();
  },
  methods: {
    getIndustryTreeData() {
      getIndustryTree().then(response => {
        this.industryOptions = response.data;
      });
    },
    handleChange(val) {
      this.$emit('input', val);
      this.$emit('change', val);
    }
  }
};
</script> 